package com.centit.dtjktxlog.dao;

import java.util.HashMap;
import java.util.Map;
import com.centit.framework.core.dao.CodeBook;
import com.centit.framework.jdbc.dao.BaseDaoImpl;
import com.centit.framework.jdbc.dao.DatabaseOptUtils;
import com.centit.support.database.utils.PageDesc;
import com.centit.support.database.utils.QueryAndNamedParams;
import com.centit.support.database.utils.QueryUtils;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.alibaba.fastjson.JSONArray;
import com.centit.dtjktxlog.po.JddtDtjktxlog;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;



/**
 * JddtDtjktxlogDao  Repository.
 * create by scaffold 2020-04-03 
 * @author codefan@sina.com
 * T_JDDT_DTJKTXLOGT_JDDT_DTJKTXLOG【动态监控提醒日志表】   
*/

@Repository
public class JddtDtjktxlogDao extends BaseDaoImpl<JddtDtjktxlog,java.lang.String>
	{

	public static final Log log = LogFactory.getLog(JddtDtjktxlogDao.class);
	
	@Override
	public Map<String, String> getFilterField() {
		if( filterField == null){
			filterField = new HashMap<String, String>();

			filterField.put("recId" , CodeBook.EQUAL_HQL_ID);


			filterField.put("airId" , CodeBook.EQUAL_HQL_ID);

			filterField.put("jksxId" , CodeBook.EQUAL_HQL_ID);

			filterField.put("jcStatus" , CodeBook.EQUAL_HQL_ID);

			filterField.put("clStatus" , CodeBook.EQUAL_HQL_ID);

			filterField.put("dqDate" , CodeBook.EQUAL_HQL_ID);

			filterField.put("zdtxTime" , CodeBook.EQUAL_HQL_ID);

			filterField.put("sctxDate" , CodeBook.EQUAL_HQL_ID);

			filterField.put("zjtxDate" , CodeBook.EQUAL_HQL_ID);

			filterField.put("rgtxTime" , CodeBook.EQUAL_HQL_ID);

			filterField.put("rgtxDate" , CodeBook.EQUAL_HQL_ID);

			filterField.put("syday" , CodeBook.EQUAL_HQL_ID);

			filterField.put("txType" , CodeBook.EQUAL_HQL_ID);

			filterField.put("dataValid" , CodeBook.EQUAL_HQL_ID);

			filterField.put("insUsercode" , CodeBook.EQUAL_HQL_ID);

			filterField.put("insTime" , CodeBook.EQUAL_HQL_ID);

			filterField.put("editUsercode" , CodeBook.EQUAL_HQL_ID);

			filterField.put("editTime" , CodeBook.EQUAL_HQL_ID);

			filterField.put("delUsercode" , CodeBook.EQUAL_HQL_ID);

			filterField.put("delTime" , CodeBook.EQUAL_HQL_ID);

		}
		return filterField;
	} 
	
	
	public JSONArray listAsJSONarray(Map<String, Object> filterMap, PageDesc pageDesc) {
		StringBuffer sb = new StringBuffer();
		sb.append("SELECT A.REC_ID,A.AIR_ID,A.JKSX_ID,B.SIGN,B.AIR_MODEL,B.NATURE,B.DT_NO,B.DTYX_DATE,C.SXNAME,A.JC_STATUS,A.CL_STATUS,A.DQ_DATE,A.ZDTX_TIME,A.SCTX_DATE,A.ZJTX_DATE,A.RGTX_TIME,A.RGTX_DATE,D.TXTYPE,A.SYDAY,A.ALARM_R,A.ALARM_Y FROM T_JDDT_DTJKTXLOG A LEFT JOIN T_AIRPLANE_BASEINFO B ON A .AIR_ID = B.REC_ID LEFT JOIN T_JDDT_JKSXGL C ON C.REC_ID = A.JKSX_ID LEFT JOIN T_JDDT_GZSZ D ON D.JKSXGL_ID = C.REC_ID WHERE 1=1");
		sb.append(" [:airId | AND A.AIR_ID = :airId] "
				+ " [:jksxId  | AND A.JKSX_ID = :jksxId] "
				+ " [:clStatus | AND A.CL_STATUS = :clStatus] "
				+ " [:jcStatus | AND A.JC_STATUS = :jcStatus] "
				+ " [:txtype | AND D.TXTYPE = :txtype] "
				+ " [:txtype | AND D.TXTYPE = :txtype] "
				+ "ORDER BY A.SYDAY");
		QueryAndNamedParams params = QueryUtils.translateQuery(sb.toString(), filterMap);
		JSONArray jsonArray = DatabaseOptUtils.listObjectsByNamedSqlAsJson(this, params.getQuery(), params.getParams(), pageDesc);
		if (jsonArray == null) {
			return new JSONArray();
		}
		return jsonArray;
	}
}
